﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Servicios.Data.DataBases.Biblioteca
{
    public partial class EditorialDTO
    {
        public EditorialDTO()
        { }

        protected override void OnPropertyChanged(string property)
        {
            base.OnPropertyChanged(property);
        }

        protected override void OnPropertyChanging(string property)
        {
            base.OnPropertyChanging(property);
        }

        #region IDataTransferObject<EditorialDTO> Members

        public List<EditorialDTO> GetAll()
        {
            using(BibliotecaContext bib = new BibliotecaContext())
            {
                var q = from editorial in bib.EditorialSet orderby editorial.Nombre select editorial;
                return q.ToList();
            }
        }

        public EditorialDTO GetByID(int id)
        {
            using(BibliotecaContext bib = new BibliotecaContext())
            {
                var q = from editorial in bib.EditorialSet where editorial.ID == id select editorial;
                return q.FirstOrDefault();
            }
        }

        public void Save()
        {
            using (BibliotecaContext bc = new BibliotecaContext())
            {
                bc.AddToEditorialSet(this);
                bc.SaveChanges();
            }
        }

        public void Update()
        {
            throw new NotImplementedException();
        }

        public void Delete()
        {
            throw new NotImplementedException();
        }

        #endregion
    }

    
}
